package xyz.robinbingo.leetcode.a20.b06.c30;

import java.util.ArrayDeque;
import java.util.Deque;

class CQueue {

    private Deque<Integer> stack1;
    private Deque<Integer> stack2;


    public CQueue() {
        stack1 = new ArrayDeque<>();
        stack2 = new ArrayDeque<>();
    }

    public void appendTail(int value) {
        while (!stack2.isEmpty()) {
            stack1.offer(stack2.poll());
        }
        stack1.offer(value);
    }

    public int deleteHead() {
        while (!stack1.isEmpty()) {
            stack2.offer(stack1.poll());
        }
        if (stack2.isEmpty()) {
            return -1;
        }
        return stack2.poll();
    }
}

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue obj = new CQueue();
 * obj.appendTail(value);
 * int param_2 = obj.deleteHead();
 */